package cms.controller.totalBill;

import cms.entity.Bill;
import cms.service.totalBillService;
import cms.util.entity.utilBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(value = "/totalBill")
public class totalBill {


    @Autowired
    private totalBillService totalBillService;


    /*
     *查询所有账单
     */
    @RequestMapping(value = "/totalBill")
    @ResponseBody
    public List<utilBill> getPartOfTotalBill(){

        System.out.println("totalBill---->Access");
        List<Bill> totalBill= totalBillService.listTotalBill();

        List<utilBill> result=new ArrayList<utilBill>();
        for (Bill bill:totalBill) {
            utilBill temp=new utilBill();
            temp.setConsumptionTime(bill.getConsumptionTime());
            temp.setConsumptionType(bill.getConsumptionType());
            temp.setGoods(bill.getGoods());
            temp.setOriginalPrice(bill.getOriginalPrice());
            temp.setDiscount(bill.getDiscount());
            temp.setAmountPrice(bill.getAmountPrice());

            result.add(temp);
        }

        return result;
    }

}
